package com.dao.impl;

import com.dao.BaseDao;
import com.dao.Import_infoDao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * 描述：
 * <p>
 * 作者：jiangjiahao
 * 时间：2023年07月01日 15:14
 */
public class Import_infoDaoImpl implements Import_infoDao {

    private Connection conn = null;
    private PreparedStatement ps = null;
    private ResultSet rs = null;

    @Override
    public Integer queryImportQuantityByMedicineId(int id) {
        conn = BaseDao.getConn();
        String sql = "select sum(QUANTITY) from import_info where MEDICINE_ID = ? and STATUS=0";
        int imsum = 0;
        try {
            ps = conn.prepareStatement(sql);
            ps.setInt(1, id);
            rs = ps.executeQuery();
            if (rs.next()){
                imsum = rs.getInt(1);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            BaseDao.closeAll(conn, ps, rs);
        }
        return imsum;
    }
}


































